import 'package:dio/dio.dart';

class NewsRequest {
  static final NewsRequest shared = NewsRequest();

  final String host = 'https://news-at.zhihu.com/';
  final dio = Dio();

  NewsRequest();

  Future<Map<String, dynamic>> fetchLastest() async {
    String path = 'api/4/news/latest';
    String url = host + path;
    final response = await dio.get(url);
    return response.data as Map<String, dynamic>;
  }

  Future<Map<String, dynamic>> fetchBefore({required String dateString}) async {
    String path = 'api/4/news/before/$dateString';
    String url = host + path;
    final response = await dio.get(url);
    return response.data as Map<String, dynamic>;
  }
}

